{extend name="Base/base"/}

{block name="body"}
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li>
                <a href="{:url('admin/Index/index')}">首页  </a>
                <i class="fa fa-circle"></i>
            </li>
            <li>
                <span>用户列表</span>
            </li>
        </ul>
        <div class="page-toolbar">
            {include file="Base/_addTo"/}
        </div>
    </div>

    <!-- 标题栏 -->
    <div class="main-title">
        <h2>{:lang('_USER_LIST_')}</h2>
    </div>
    <div class="clearfix">
        <div class="col-xs-9 pd0">
            <button class="btn ajax-post" url="{:url('User/changeStatus',array('method'=>'resumeUser'))}"
                    target-form="ids">{:lang('_ENABLED_')}
            </button>
            <button class="btn ajax-post" url="{:url('User/changeStatus',array('method'=>'forbidUser'))}"
                    target-form="ids">{:lang('_DISABLE_')}
            </button>
            <button class="btn ajax-post confirm" url="{:url('User/changeStatus',array('method'=>'deleteUser'))}"
                    target-form="ids">{:lang('_DELETE_')}
            </button>
            <button class="btn " onclick="post_select_form()"
                    target-form="ids">{:lang('_USER_GROUP_SELECT_')}
            </button>
            <button class="btn ajax-post" url="{:url('User/emailSuffix')}"
                    target-form="ids">修改第三方登录邮箱后缀
            </button>
            <button class="btn ajax-post confirm" data-confirm="{:lang('_PW_RESET_CONFIRM_')}" url="{:url('admin/User/initPass')}" target-form="ids">{:lang('_PW_RESET_')}
            </button>
            <span style="font-size: 14px;color: #999898;margin-left: 11px;">{:lang('_PW_RESET_TIP_')}</span>
        </div>
        <script>
            function post_select_form(){
                var ids=$('.ids').serialize();
                var title="{:lang('_USER_GROUP_SELECT_')}";
                $.post("{:url('admin/User/changeGroup')}",ids,function(msg){
                    (new $.zui.ModalTrigger({custom: msg,title:title})).show();
                })
            }
        </script>

        <!-- 选择搜索方式 -->
        <div class=" col-xs-1">
            <select id="seek" name="seek" class="form-control" style="width: 108px">
                <option value="0" {if condition="$seek eq 0"}selected{/if} >{:lang('_SELECT_WAY_')}</option>
                <option value="1" {if condition="$seek eq 1"}selected{/if} >{:lang('_UID_')}</option>
                <option value="2" {if condition="$seek eq 2"}selected{/if} >{:lang('_NICKNAME_')}</option>
                <option value="3" {if condition="$seek eq 3"}selected{/if} >{:lang('_MAILBOX_')}</option>
                <option value="4" {if condition="$seek eq 4"}selected{/if} >{:lang('_CELL_PHONE_NUMBER_')}</option>
            </select>
            <input type="hidden" name="seek" value="{$seek}"/>
        </div>

        <!-- 高级搜索 -->
        <div class="search-form col-xs-2 text-right">
            <div class="input-group">
                <input type="text" name="nickname" class="search-input form-control" value="{:input('nickname')}"
                       placeholder="{:lang('_PLACEHOLDER_NONE_')}">
                                 <span class="input-group-btn">  <a class="btn btn-default" href="javascript:;" id="search" url="{:url('index')}"><i class="fa fa-search"></i></a></span>
            </div>
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table with-padding adminlte-os-table">
        <table class="table table-bordered table-striped table-hover">
            <thead>
            <tr>
                <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                <th class="">{:lang('_UID_')}</th>
                <th class="">{:lang('_USERNAME_')}</th>
                <th class="">{:lang('_MAILBOX_')}</th>
                <th class="">{:lang("_CELL_PHONE_NUMBER_")}</th>
                <th class="">{:lang("_NICKNAME_")}</th>
                <th class="">{:lang("_OPERATE_")}</th>
                <th class="">{:lang('_LOGIN_COUNT_')}</th>
                <th class="">{:lang('_LAST_LOGIN_TIME_')}</th>
                <th class="">{:lang('_LOGIN_IP_LAST_TIME_')}</th>
                <th class="">{:lang('_STATUS_')}</th>

            </tr>
            </thead>
            <tbody>
            {notempty name="_list"}
                {volist name="_list" id="vo"}
                    <tr>
                        <td><input class="ids" type="checkbox" name="id[]" value="{$vo.uid}"/></td>
                        <td>{$vo.uid}</td>
                        <td>{$vo.ext.username}</td>
                        <td>{$vo.ext.email}</td>
                        <td>{$vo.ext.mobile}</td>
                        <td><a href="{:url('Admin/User/expandinfo_details',array('uid'=>$vo['uid']))}" >{$vo.nickname|op_t}</a></td>
                        <td>
                            {eq name="vo.status" value="1"}
                                <a href="{:url('admin/User/changeStatus?method=forbidUser&id='.$vo['uid'])}"
                                   class="ajax-get">{:lang('_DISABLE_')}</a>
                                {else/}
                                <a href="{:url('admin/User/changeStatus?method=resumeUser&id='.$vo['uid'])}"
                                   class="ajax-get">{:lang('_ENABLE_')}</a>
                            {/eq}
                            <a href="{:url('admin/AuthManager/group?uid='.$vo['uid'])}" class="authorize">{:lang('_ACCREDIT_')}</a>
                            <a href="{:url('admin/User/changeStatus?method=deleteUser&id='.$vo['uid'])}"
                               class="confirm ajax-get">{:lang('_DELETE_')}</a>
                            <a href="{:url('admin/User/initPass?id='.$vo['uid'])}"
                               class="confirm ajax-get">{:lang('_PW_RESET_')}</a>
                        </td>



                        <td>{$vo.login}</td>
                        <td><span>{$vo.last_login_time|time_format}</span></td>
                        <td><a target="_blank" href="http://ip138.com/ips138.asp?ip={$vo['last_login_ip']|long2ip}">{$vo['last_login_ip']|long2ip}</a>
                        </td>
                        <td>{$vo.status}</td>



                    </tr>
                {/volist}
                {else/}
                <td colspan="12" class="text-center">{:lang('哇哦，查无此人')}</td>
            {/notempty}
            </tbody>
        </table>
    </div>
    <div class="with-padding">
        {$page}
    </div>
{/block}

{block name="script"}
{load href="admin/static/js/thinkbox/jquery.thinkbox.js" /}

    <script type="text/javascript">
        //选择搜索方式
        $("#seek").change(function() {
            var pick = $(this).val();
            switch (pick) {
                case '0':
                    $(".search-input").attr("placeholder", "{:lang('_PLACEHOLDER_NONE_')}");
                    break;
                case '1':
                    $(".search-input").attr("placeholder", "{:lang('_PLACEHOLDER_UID_')}");
                    break;
                case '2':
                    $(".search-input").attr("placeholder", "{:lang('_PLACEHOLDER_NICKNAME_')}");
                    break;
                case '3':
                    $(".search-input").attr("placeholder", "{:lang('_PLACEHOLDER_EMAIL_')}");
                    break;
                case '4':
                    $(".search-input").attr("placeholder", "{:lang('_PLACEHOLDER_MOBILE_')}");
                    break;
                default:
                    $(".search-input").attr("placeholder", "{:lang('_PLACEHOLDER_NONE_')}");
            }
        });
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            var seek = $('#seek').serialize();

            if(seek == 'seek=0') {
                toast.error("请先选择搜索用户的方式!");
                return false;
            }
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');

            seek = seek.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            seek = seek.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query + '&' + seek;
            } else {
                url += '?' + query + '&' + seek;
            }
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
        //导航高亮
        highlight_subnav("{:url('admin/User/index')}");
    </script>
{/block}